<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户模板费率列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">模板编号：</label>
                                <input type="text" name="modelNo"/>
                            </li>
                            <li>
                                <label style="width: 100px;">模板名称：</label>
                                <input type="text" name="modelName"/>
                            </li>
                            <li>
                                <label style="width: 100px;">模板类型：</label>
                                <select name="modelType" th:with="type=${@dict.getType('modelType')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">是否显示：</label>
                                <select name="isShow" th:with="type=${@dict.getType('isShow')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">是否默认：</label>
                                <select name="isDefault" th:with="type=${@dict.getType('isDefault')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">添加时间：</label>
                                <input type="text" class="time-input" readonly placeholder="开始时间" name="startDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" readonly placeholder="结束时间" name="endDate"/>
                            </li>
                            <li>
                                <label style="width: 10px;"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="merchant:MerchantModel:add">
                    <i class="fa fa-plus"></i> 添加模版
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="merchant:MerchantModel:edit">
                    <i class="fa fa-edit"></i> 编辑模版
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('merchant:MerchantModel:edit')}]];
        var removeFlag = [[${@permission.hasPermi('merchant:MerchantModel:remove')}]];
        var modelTypeDatas = [[${@dict.getType('modelType')}]];
        var isShowDatas = [[${@dict.getType('isShow')}]];
        var isDefaultDatas = [[${@dict.getType('isDefault')}]];
        var prefix = ctx + "merchant/merchantModel";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商户模板费率",
                firstLoad:true,
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键编号',
                    visible: false
                },
                {
                    field: 'modelNo',
                    title: '模板编号',
                    align: 'center'
                },
                {
                    field: 'modelName',
                    title: '模板名称',
                    align: 'center'
                },
                {
                    field: 'modelType',
                    title: '模板类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(modelTypeDatas, value);
                    },
                    align: 'center'
                },
                {
                    field: 'isShow',
                    title: '是否显示',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(isShowDatas, value);
                    },
                    align: 'center'
                },
                {
                    field: 'isDefault',
                    title: '是否默认',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(isDefaultDatas, value);
                    },
                    align: 'center'
                },
              /*  {
                    field: 'proName',
                    title: '产品名称',
                    align: 'center'
                },*/
                {
                    field: 'rateValue',
                    title: '费率值描述',
                    align: 'center'
                },
                {
                    field: 'addTime',
                    title: '添加时间',
                    align: 'center'
                },
                {
                    field: 'addMan',
                    title: '添加人',
                    align: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="setModelDetailsRate(\'' + row.modelNo + '\',\'' + row.modelType + '\')"><i class="fa fa-edit"></i>设置模版费率</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="delModel(\'' + row.modelNo + '\')"><i class="fa fa-remove"></i>删除模版</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /**
         * 设置商户费率模版
         */
        function setModelDetailsRate(modelNo,modelType) {
            if (modelType == '1'){
                $.modal.open("配置附加费率", ctx + "merchant/merchantModel/addFj?modelNo="+modelNo,"800","350");
            } else {
                $.modal.open("配置模版费率", ctx + "merchant/merchantModel/setModelDetailsRate?modelNo="+modelNo,"1100","700");
            }
        }

        /**
         * 删除模版
         * @param modelNo
         */
        function delModel(modelNo) {
            $.modal.confirm("确定要删除当前费率模版吗？", function() {
                var data = { "modelNo": modelNo };
                $.operate.post(prefix + "/remove", data);
            })
        }



    </script>
</body>
</html>